magiclanternfandomcom-20200223-history
DbgMgr
General Notes Findings by: Coutts There are 2 functions of interest, dm_set_store_level and dm_set_print_level. Stubs can be found here (from 500d): 0xFF066DE4 - dm_set_store_level 0xFF066D7C - dm_set_print_level Different debug messages in the firmware are posted with different classes. The class is arg0 to the debug message. This class determines what shows up for a name in the log, i.e.: GUI, STARTUP, MAGIC, etc. The second argument to a debug message is the print level. Refer to the section below for understanding the level system implemented by canon. dm_set_store_level Usage (after finding stub): dm_set_store_level( class_id, store_level ); dm_set_print_level This function behaves identical to dm_set_store_level, so all of the classes above will apply. I do not yet understand just what the print level affects, but I do know that setting a lower store_level seems to produce larger debug log files. To use this, just refer to dm_set_store_level above. Debug Classes class_id can be any number between 1 and 255. I have mapped out all of the known values below. Any missing ones didn't print in my test for some reason, it could just be the 500d - would be nice if someone can confirm these classes on another camera. Store Levels There are 15 levels, 1-15. Basic rule of thumb: higher number will hide debug messages and a lower one will show them. Think of the store level as a value-floor (limiter) for what messages will be printed. Any debug message with a level lower than what's currently set by dm_set_store_level for a specific class, won't be printed in the log. Let's take this for an example: DryosDebugMsg( 0x83, 0x3, "This is a GUI debug message"); The default store level seems to be 3, so this message will print. Say I want to hide this message (or any GUI messages with a store level of 3 for that matter). Simple, just call dm_set_store_level: dm_set_store_level( 0x83, 0x4); Since the store level for this class (0x83 - GUI) is now higher than what's being passed in the debug messages, no debug message will be stored in the log for this class. The reason that everybody thought a store level of 7 was a magic number for turning off debug messages is because 7 is a higher level than almost all debug messages in the dump, so it works well for turning off messages. DbgMgr Struct in memory I have found some kind of structure in memory for each debug class which contains the actual values for dm_store_level and dm_print_level. Each class has it's own spot in this (array of structures?) area of memory. The store levels are stored as bytes, so don't forget to take this into account when looking at ram dumps ;) *off_0x14 holds the dm_store_level *off_0x15 holds the dm_print_level Find VRAM addresses by Coutts in 500D Keep in mind that the known HD buffers in the 500d are at 0x46000080 and 0x48000080 8026: 26858.706 LVCFG LVREC Free Yuv 46000064 8027: 26858.763 RSC SRM_FreeMemoryResourceForLiveViewYuv 0x46000064 8028: 26858.827 LVCFG LVREC Free Yuv 48000064 8029: 26858.869 RSC SRM_FreeMemoryResourceForLiveViewYuv 0x48000064 8033: 26859.363 RSC this->dwLVYUV 1 8035: 26860.124 RSC this->dwLVYUV 0 8345: 29739.697 LVCFG LVREC AllocMemYuv1 Addr:48000064-48000080 8354: 29770.936 LVCFG YuvAddress = 0x48000064 -> 0x48000080 8357: 29771.190 LVCFG LVREC AllocMemYuv2 Addr:48000064-48000080 8359: 29771.584 LVCFG YuvAddress = 0x46000064 -> 0x46000080 8833: 31321.728 LVCFG LVREC Free Yuv 48000064 8834: 31321.789 RSC SRM_FreeMemoryResourceForLiveViewYuv 0x48000064 8835: 31321.856 LVCFG LVREC Free Yuv 46000064 8836: 31321.895 RSC SRM_FreeMemoryResourceForLiveViewYuv 0x46000064 8840: 31322.412 RSC this->dwLVYUV 1 8842: 31323.147 RSC this->dwLVYUV 0 in another log, after doing some video recording. These messages are in play mode watching a clip. 9469: 33747.617 MP StartResizeMotionJpeg(0, 0x43738800) 9478: 33754.900 MP DeleteVram0(0x43738800) 9551: 34761.695 MP MVP_GetRecWorkBuffSize(0x91920c70) 9554: 34762.679 MP MVP_GetPlayWorkBuffSize(0x91920c70) 9555: 34762.717 MP MVP_GetPlayWorkBuffSize : Decode Size(1884160 x 2) 9559: 34763.407 MP MVP_GetStreamBuffSize(0x91920c70) 9562: 34799.175 MP MVP_OpenMoviePlay(0x91920c70) 9563: 34799.231 MP MVP_OpenMoviePlay : Decode Size1884160(1280,720) 9564: 34799.270 MP MVP_OpenMoviePlay : DecBuff0x48000064,0x481cc064 9565: 34799.296 MP VramAddress0=0x41b07800 9566: 34799.318 MP VramAddress1=0x43738800 9567: 34799.341 MP VramAddress2=0x43b48800 9568: 34799.364 MP_MOV OpenMovReadFile(B:/DCIM/100CANON/MVI_8391.MOV) 9569: 34799.454 MP_MOV ReadMovHeader 9570: 34801.619 MP_MOV ReadMovHeader : AtomType(ftyp) 9571: 34802.810 MP mvpGetVramNum : ImageAddress0x43738800 9572: 34802.835 MP mvpGetVramNum : VramNum=1 9669: 35372.854 MP mvpGetVramNum : ImageAddress0x43738800 9670: 35372.873 MP mvpGetVramNum : VramNum=1 9671: 35372.922 MP CreateVram2(0x43b48800,720,720,480) 9673: 35376.228 MP CreateVram0(0x41b07800,720,720,480) 9888: 36088.830 MP -- STATE_PLAYING_PLAY -- 9895: 36095.442 MP mvpResizeCompleteCallback 9896: 36095.516 MP mvpResizeCompleteCallback 9904: 36102.261 MP mvpDecodeCompleteCallback 9912: 36118.581 MP PlayMovie :rd(3),dec(2),res(1),resC(1),dspC(0) 9913: 36118.609 MP PlayMovie : (0,1,0,0) 9914: 36118.664 MP PlayMovie : SetRectColorParameter(0x43738800,720,720,480) 9917: 36121.852 MP ChangeVramCallBack 9918: 36121.869 MP ChangeVramCallBackExec 9920: 36122.328 MP ChangeNextUpdateVram0(0x41b07800) 9921: 36122.386 MP StartResizeMotionJpeg(1, 0x43738800) all 3 of the 500d's identified LV vram buffers are there, again this could be useful for new cameras. :) See VRAM/500D On 550D/1.0.9 dm_set_store_level( DM_DISP, 7 ); gives: 20741: 3027.786 DISP SetImageVramParameter pAddress='40d07800 '''pFlipCBR=0 20742: 3027.840 DISP SetImageOverrideParameter ClassID=152, Override=-1 20743: 3027.983 DISP EnableImagePhysicalScreenParameter pCBR=ff0350f8 20744: 3028.117 LVCDEV ->lvcdevStartDev 20745: 3029.292 ENG LockEng 0xac41c0LVC_DEV 20746: 3029.857 ENG LockEng 0x8bd1d8LVC_FACE 20747: 3033.701 DISP VdInterruptHandler bmp=0 img=ff0350f8 20748: 3035.308 ENG UnLockEng 0xac41c0LVC_DEV 20749: 3053.523 ENG UnLockEng 0x8bd1d8LVC_FACE 20752: 3060.867 LVP GetJpegEncodePass Zoom:0 R:0 V:1 M:0 20753: 3061.300 DISP SetImageVramParameter pAddress='4c233800 'pFlipCBR=0 20754: 3061.356 DISP SetImageOverrideParameter ClassID=152, Override=-1 20755: 3061.489 DISP EnableImagePhysicalScreenParameter pCBR=ff0350f8 20756: 3061.631 LVCDEV ->lvcdevStartDev 20757: 3062.833 ENG LockEng 0xac41c0LVC_DEV 20758: 3067.071 DISP VdInterruptHandler bmp=0 img=ff0350f8 20759: 3068.845 ENG UnLockEng 0xac41c0LVC_DEV 20760: 3094.476 LVP GetJpegEncodePass Zoom:0 R:0 V:1 M:0 20761: 3094.921 DISP SetImageVramParameter pAddress='4f11d800 '''pFlipCBR=0 20762: 3094.976 DISP SetImageOverrideParameter ClassID=152, Override=-1 20763: 3095.099 DISP EnableImagePhysicalScreenParameter pCBR=ff0350f8 This code: int (*GetVramInformation)(uint8_t *v1, uint8_t *v2, uint8_t *v3, uint8_t *v4, uint8_t *v5, uint8_t *v6, uint8_t *v7 ) = (void*)0xFF28E894; GetVramInformation(&v1, &v2, &v3, &v4, &v5, &v6, &v7); bmp_printf( FONT_SMALL, x, y+20, "GetVramInformation v1=%x v2=%x v3=%x v4=%x v5=%x v6=%x v7=%x", v1, v2, v3, v4, v5, v6, v7 ); DebugMsg( DM_MAGIC, 3, "GetVramInformation v1=%x v2=%x v3=%x v4=%x v5=%x v6=%x v7=%x", v1, v2, v3, v4, v5, v6, v7 ); gives: v1=0x40d078000, v2=2, v3=0x4c233800, v4=0, v5=720, v6=720, v7=480 which Class_ID to use ? To know which class_id to use, look R0, the first arg of DebugMsg ROM:FF012248 ADR R2, aStartupentry ; "startupEntry" ROM:FF01224C MOV R1, #5 ROM:FF012250 MOV R0, #0x8B ;139 ROM:FF012254 BL DebugMsg the related log entry is 7: 13.020 STARTUP startupEntry so use dm_set_store_level( 139, level); in your code to debug STARTUP things...